<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
 <script>
            window.onload = function () {
                document.getElementById('txt1').onfocus = function () {
                    alert(1);
                };
            };
    </script>
</head>
<body>
        <input id="txt1" type = 'password'/>
</body>
</html>